// ==UserScript== // @name ChatGPT撑开页面宽度 // @namespace https://greasyfork.org/ // @version 1.1.3 // @description 将页面宽度展开 // @author OpenAI - ChatGPT // @match https://chat.openai.com/ // @match https://chat.openai.com/c/* // @match https://chat.openai.com/?* // @license AGPL-3.0-or-later // ==/UserScript== (function () { "use strict"; const newMaxWidth = "90rem"; const targetClassName = ".xl\\:max-w-3xl"; const targetClass = "flex flex-col text-sm dark:bg-gray-800"; const desiredMinWidth = 1280; const styleId = "await-max-width"; const btnId = "await-btn"; // const btnSvgId = "await-svg"; const btnShowTipId = "await-show-tip"; const textClass = "await-text"; function getById(id) { const btn = document.getElementById(id); if (!btn) { setTimeout(function () { return getById(); }, 1000); } return btn; } function styleCreate() { const style = document.createElement("style"); style.innerHTML = ` .${styleId} { max-width: ${newMaxWidth} !important; } .${btnId}{ right:2.8rem; } .${textClass}{ } `; document.head.appendChild(style); } function btnClickAdd() { //在 id为prompt-textarea的元素后面添加一个btnClick按钮 const promptTextarea = document.getElementById("prompt-textarea"); if (!promptTextarea) { setTimeout(function () { btnClickAdd(); }, 1000); return; } promptTextarea.insertAdjacentHTML( "afterend", ` ` ); } function removeStyle(el) { el.classList.remove(styleId); } function editStyle(el) { el.style.transition = "max-width 1s"; setTimeout(function () { el.style.transition = ""; }, 1000); el.classList.add(styleId); } function openSvg() { const btn = getById(btnId); //替换btn的svg btn.innerHTML = ""; btn.insertAdjacentHTML( "afterbegin", `撑开` // `` ); // btn.insertAdjacentHTML( // "afterbegin", // `` // ); btn.addEventListener("click", function () { checkObserver(1); closeSvg(); }); } function closeSvg() { const btn = getById(btnId); btn.innerHTML = ""; btn.insertAdjacentHTML( "afterbegin", `还原` ); // btn.insertAdjacentHTML( // "afterbegin", // `` // ); btn.addEventListener("click", function () { checkObserver(2); openSvg(); }); } function showTip() { styleCreate(); const toggleButton = document.querySelector("nav"); if (!toggleButton) { setTimeout(function () { showTip(); }, 1000); return; } toggleButton.insertAdjacentHTML( "beforeend", `